<template>
    <div class="wrapper">
        <head-bar height="80" middleText="文章详情" style="position: absolute;top: 0;left: 0;" :leftClick="returnPage" :rightClick="downloadFile" :rightText="info && info.contentFileKey ? '下载附件':''"></head-bar>
        <div class="webview-box">
            <web class="webview" :src="_webViewUrl"  @pagefinish="onPageFinish"></web>
        </div>
    </div>
</template>

<style>
    .webview{
        position: absolute;
        top: 0 ;
        left: 0;
        right:0;
        bottom: 0;
    }

    .webview-box {
        position: absolute;
        top: 114px ;
        left: 0;
        right:0;
        bottom: 0;
    }
    .wrapper{
        position: absolute;
        left: 0;
        right:0;
        bottom: 0;
        top:0;
    }

</style>

<script>
    import {WxcRichText, WxcSpecialRichText} from 'weex-ui';

    import headBar from '../components/headBar.vue'
    import nw from '../network/nw.js'
    import dtl from '../utils/dateUtils.js'

    const dom = weex.requireModule('dom')

    var pref = weex.requireModule('pref')

    const url = {
        detail: '/app/yxq/article/',
        articleLike: '/app/yxq/article/like'
    }



    export default {
        data: {
            webViewStyle: null,
            webViewUrl:`${nw.host}views/html5/yxq/article/article_detail.html`,
            param:{},//跳转页面参数
        },
        components: {headBar, WxcRichText, WxcSpecialRichText},
        computed: {
            _webViewUrl:function () {
                return `${this.webViewUrl}?id=${this.param.id}&sid=${pref.getString('sid')}`
            }
        },
        methods: {
            downloadFile(){
                var modal=weex.requireModule('modal')
                modal.toast({message:'该功能暂未开放'})
            },

            //返回上个页面
            returnPage: function () {
                var nav = weex.requireModule('navigator')
                nav.back()
            },

            onPageFinish: function (e) {
                var self = this
                dom.getComponentRect(this.$refs.webview, option => {
                    self.webViewStyle = option.size
                })

            },

            onLoad(){
                const navigator = weex.requireModule('navigator')
                this.param = navigator.param()
            }
        }
    }
</script>